package com.sleepcamel.rest.domain.sourcegenerator;

import org.stringtemplate.v4.ST;
import org.stringtemplate.v4.STGroupFile;

import com.sleepcamel.rest.domain.ISourceCodeGenerable;

public class MethodSourceGenerator implements ISourceCodeGenerator{

	private static STGroupFile stGroupFile;
	private ST classTemplate;
	private ST interfaceTemplate;
	
	static {
		stGroupFile = new STGroupFile("templates/java/MethodJava.stg");
		stGroupFile.load();
	}
	
	public void setData(ISourceCodeGenerable method) {
		classTemplate = stGroupFile.getInstanceOf("MethodClassJavaSource");
		classTemplate.add("method", method);
		interfaceTemplate = stGroupFile.getInstanceOf("MethodInterfaceJavaSource");
		interfaceTemplate.add("method", method);
	}

	public String generateInterfaceSource() {
		return interfaceTemplate.render();
	}
	
	public String generateClassSource() {
		return classTemplate.render();
	}

}
